/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TShop;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TShopDao;
import com.ruipengkj.service.TShopService;
/**
 * 说明：
 * 商店Service层接口
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TShopServiceImpl implements TShopService{
	@Resource
	private TShopDao TShopDao;//DAO层
	
	//查询所有
	@Override
	public List<TShop> findService(TShop entity) throws Exception {
		String hql = "select o from TShop o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TShopDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TShop> getScrollService(int firstResult,
			int maxResult, TShop entity) throws Exception {
		String hql = "select o from TShop o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TShopDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	//修改
	@Override
	public void modifyService(TShop entity) throws Exception {
		TShopDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TShop entity) throws Exception {
		TShopDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TShopDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TShop getByIdService(String id) throws Exception {
		return TShopDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TShop entity) throws Exception {
		TShopDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TShop entity) throws Exception {
		return TShopDao.saveRetDao(entity);
	}
	public TShopDao getTShopDao() {
		return TShopDao;
	}

	public void setTShopDao(TShopDao TShopDao) {
		this.TShopDao = TShopDao;
	}
}